<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>${_title}</title>

    <!-- Bootstrap core CSS -->

    <link href="${_css}/bootstrap.min.css" rel="stylesheet">

    <link href="${_font}/css/font-awesome.min.css" rel="stylesheet">
    <link href="${_css}/animate.min.css" rel="stylesheet">

    <!-- Custom styling plus plugins -->
    <link href="${_css}/custom.css" rel="stylesheet">
    <link href="${_css}/icheck/flat/green.css" rel="stylesheet">
    <link href="${_css}/datatables/tools/css/dataTables.tableTools.css" rel="stylesheet">
	<link rel="stylesheet" href="${_css}/base.css">
    <script src="${_js}/jquery.min.js"></script>
	<script type="text/javascript" src="${_js}/common.js"></script>
	<script src="${_js}/resize.js"></script>
	<script type="text/javascript" src="${_front_js}/jquery.page.js"></script>
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
	<style>
		td a{
			cursor:pointer
		}
		
		.about-bank{
			width:450px;
		}
		
		#export{
    		color: #fff;
    		background-color: #1A82C3;
    		border-color: #1A82C3;
		}
	</style>
	<script type="text/javascript">
		$(window).load(function (){ 
			var href=window.location.href;
			var action=$("#example").attr('data-action');
			$("#withdraw-tab li").each(function(){
	    		var status=$(this).find('a').attr('data-status');
	    		if(href==action){
	    			$(this).addClass('active');
	    			$("#example").attr('data-action',action);
	    			$("#example").attr('data-hash',status);
	    			return false;
	    		}
	    	}) 
		});
	</script>
</head>


<body style="background: #F7F7F7;">
<div class="">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
	            <div class="x_title">
					<h2>用户充值列表</h2>
					<div class="clearfix"></div>
				</div>
                <div >
                	<button id="query" type="button" class="btn btn-info">查询</button>
                	<button id="offLineOper" type="button" class="btn btn-info">线下充值</button>
                	<button id="export" type="button" class="btn" >导出</button>
                </div> 
                <form class="form-horizontal form-label-left input_mask" id="rechargeForm">
                	<div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" id="username" name="username" value="<#if username?exists>${username}</#if>"
                        placeholder="输入用户名">
                        <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <select class="form-control" id="status" name="status">
                        	<option value="">--请选择充值状态--</option>
							<option value="success" <#if status?exists & status=='success'>selected="selected"</#if>>成功</option>
							<option value="failure" <#if status?exists & status=='failure'>selected="selected"</#if>>失败</option>
						</select>
                    </div>
                     <div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <select class="form-control" id="isOffLine" name="isOffLine">
                        	<option value="">--请选择提现方式--</option>
							<option value="1" <#if isOffLine?exists & isOffLine=='1'>selected="selected"</#if>>线下</option>
							<option value="" <#if isOffLine?exists & isOffLine!='1'>selected="selected"</#if>>线上</option>
						</select>
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-5 form-group has-feedback">
                        <select class="form-control" id="match" name="match">
                        	<option value="">--请选择匹配符--</option>
							<option value="GT" <#if match?exists & match=='GT'>selected="selected"</#if>>大于</option>
							<option value="LT" <#if match?exists & match=='LT'>selected="selected"</#if>>小于</option>
							<option value="GE" <#if match?exists & match=='GE'>selected="selected"</#if>>大于等于</option>
							<option value="LE" <#if match?exists & match=='LE'>selected="selected"</#if>>小于等于</option>
							<option value="NE" <#if match?exists & match=='NE'>selected="selected"</#if>>不等于</option>
							<option value="EQ" <#if match?exists & match=='EQ'>selected="selected"</#if>>等于</option>
						</select>
                    </div>
                    <div class="col-md-2 col-sm-2 col-xs-6 form-group has-feedback">
                        <input type="text" class="form-control has-feedback-left" id="money" name="money"
                        onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
                        value="<#if money?exists>${money}</#if>"
                        placeholder="输入充值金额">
                        <span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
                    </div>
                    <form class="form-horizontal">
						<fieldset>
							<div class="control-group">
								<div class="controls">
									<div class="input-prepend input-group">
										<span class="add-on input-group-addon">
											<i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
										</span>
										<input type="text" style="width: 200px" name="rechargeTime" id="reservation" placeholder="请选择充值时间段"
										class="form-control" value="" />
									</div>
								</div>
							</div>
						</fieldset>
					</form>
					<input type="hidden" name="status" id="rechargeStatus" value="<#if status??>${status}</#if>"/>
                 </form>                   
                <div class="clearfix"></div>
            </div>
            <div class="scroll">
                <div class="x_content">

                    <div class="" role="tabpanel" data-example-id="togglable-tabs">
                        <ul id="example-tab" class="nav nav-tabs bar_tabs" role="tablist">
                            <li role="presentation" data-hash="success" class="<#if status?exists & status='success'>active</#if>">
                            	<a href="#tab_content1"  role="tab" data-toggle="tab" aria-expanded="false">充值信息列表</a>
                            </li>
                        </ul>
                        <span style="float:right; position: absolute;right: 16px;margin-top: -60px;font-size: 16px;color: red;">总充值金额:
							 <#if pageInfo.sum?exists>
                            		<#if (pageInfo.sum != 0 )>
                                		￥${pageInfo.sum?string('0.00')}
                                	<#else>
                                	 	￥0.00
                                	</#if>   
                              <#else>
                                	 	￥0.00  	
                              </#if>   	                     
                        </span>
                        <div id="myTabContent" class="tab-content">
                            <div role="tabpanel" class="tab-pane fade active in" id="tab_content1" aria-labelledby="home-tab">
				                <div class="x_content">
				                    <table id="example" data-action="/admin/recharge/list?" class="table table-striped responsive-utilities jambo_table">
				                        <thead>
				                            <tr class="headings">
				                                <th>
				                                    <input type="checkbox" class="tableflat">
				                                </th>
				                                <th>序号 </th>
				                                <th>订单号</th>
				                                <th>充值用户</th>
				                                <th>真实姓名</th>				                                
				                                <th>手机号</th>				                                
				                                <th>支付途径 </th>
				                                <th>状态</th>
				                                <th>充值金额 (￥)</th>
				                                <th>申请时间 </th>
				                                <th>充值方式</th>
				                            </tr>
				                        </thead>
				
				                        <tbody class="tbody">
							                <#if (pageInfo?exists) && (pageInfo.pageList?size > 0)>
												<#list pageInfo.pageList as item>
													<tr class="even pointer">
						                                <td class="a-center ">
						                                    <input type="checkbox" class="tableflat" data-id="${item.id}">
						                                </td>
						                                <td>
						                                	${item_index+1}
						                                </td>
						                                <td>
						                                	${item.code}
						                                </td>
						                                <td>
						                                	<a data-toggle="modal" data-id="${item.userId}" data-target=".user-info" class="btn-user"><#if item.username?exists>${item.username}</#if></a>
						                                </td>	
						                                <td>
						                                	<#if item.realname?exists>
							                                	${item.realname}
						                                	</#if>
						                                </td>
						                                <td>
						                                	<#if item.phone?exists>
						                                	${item.phone}
						                                	</#if>
						                                </td>						                                						                                	                                
						                                <td>
						                                	<#if item.payMethod?exists>
						                                		${item.payMethod}
						                                	</#if>
						                                </td>						                                
						                                <td>
						                                	<#if item.status?exists && item.status=="success">
						                                		充值成功
						                                	<#else>
						                                		充值失败
						                                	</#if>
						                                </td>						                                
						                                <td>
						                                	<#if item.money?exists>
						                                		<#if (item.money != 0 )>
							                                		${item.money?string('0.00')}
							                                	<#else>
							                                	 	0.00
							                                	</#if>
						                                	</#if>
						                                </td>
						                                <td>
						                                	${(item.createTime?string("yyyy-MM-dd HH:mm:ss"))!}
						                                </td>
						                                <td>
						                                <#if (item.isOffLine?exists) && (item.isOffLine=="1")>线下<#else>线上</#if>
						                                </td>
						                             </tr>   
						                        </#list>
											<#else>
												<tr class="even pointer">
													<td colspan="11">无记录</td>
												</tr>
											</#if>
				                        </tbody>
				                    </table>
				                    <#if (pageInfo.pageList?size > 0)>
				                    	<#include "../base/Page.ftl">
				                    </#if>
				                </div>
                            </div>
                       </div>
                   </div>
             </div>
        </div>
    </div>
</div>

<!--手动充值 -->
<div class="modal fade bs-example-modal-sm add-recharge" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm about-bank">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="myModalLabel2">手动充值</h4>
            </div>
            <div class="modal-body">
                 <form class="form-horizontal form-label-left" novalidate>
					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">用户名
                        </label>
                        <div class="col-md-6 col-sm-8 col-xs-12">
                            <input id="userName" class="form-control col-md-6 col-xs-12" type="text">
                            <a class="btn btn-success btn-check" style="position: absolute;margin-left: 15px;">检查</a>
                        </label>
                        </div>
                    </div>
					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">手机号码/用户名
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="phone" readonly="readonly" class="form-control col-md-8 col-xs-12" type="text">
                        </label>
                        </div>
                    </div>                    
                    <div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">充值金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="amount" class="form-control col-md-7 col-xs-12" type="text">
                        </label>
                        </div>
                    </div>     
                    <div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">确认金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="reAmount" class="form-control col-md-7 col-xs-12" type="text">
                        </label>
                        </div>
                    </div>      
                    <input type="hidden" id="userId">                                                
                 </form>   
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">充值</button>
            </div>
        </div>
    </div>
</div>

<!--用户相关信息 -->
<div class="modal fade bs-example-modal-sm user-info" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-sm about-bank">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="myModalLabel2">充值用户信息</h4>
            </div>
            <div class="modal-body">
                 <form class="form-horizontal form-label-left" novalidate>
					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">用户名
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="usernameI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">手机号码
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="phoneI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>                                      
                    <div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">实名认证姓名
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="realnameI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">账户总金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="totalAmountI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>
                    <div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">账户冻结金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="freezenI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>
 
					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">账户待收金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="awaitI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>  

					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">账户待还金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="repayI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>  

					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">账户总充值金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="totalRechargeI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>      

					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12" for="name">账户历史提现总金额
                        </label>
                        <div class="col-md-8 col-sm-8 col-xs-12">
                            <input id="totalWithdrawI" class="form-control col-md-7 col-xs-12"  value="" readonly="readonly" type="text">
                        </label>
                        </div>
                    </div>                                                        
                 </form>   
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>

        </div>
    </div>
</div>

<!--审核手动充值 -->
<div class="modal fade bs-example-modal-sm auditRecharge" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm about-bank">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="myModalLabel2">审核手动充值</h4>
            </div>
            <div class="modal-body">
                 <form class="form-horizontal form-label-left" novalidate>
                 	<input id="rechargeRecordId" type="hidden" value=""/>
					<div class="item form-group">
                        <label class="control-label col-md-4 col-sm-4 col-xs-12">审核
                        </label>
                        <input type="radio" id="pass" class="flat result" checked="checked"
        					name="isPass" value="1">通过
    					<input type="radio" id="unPass" class="flat result"
        					name="isPass" value="0">不通过
                    </div>
                    <div class="item form-group">
	                    <label class="control-label col-md-4 col-sm-4 col-xs-12" for="verifyRemark">审核备注
	                    </label>
	                    <div class="col-md-8 col-sm-8 col-xs-12">
	                        <input id="verifyRemark" class="form-control col-md-8 col-xs-12" type="text">
	                    </label>
	                    </div>
	                </div>
                 </form>   
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary check-submit recharge-submit">提交</button>
            </div>
        </div>
    </div>
</div>

<script src="${_js}/bootstrap.min.js"></script>

<!-- bootstrap progress js -->
<script src="${_js}/progressbar/bootstrap-progressbar.min.js" type="text/javascript"></script>
<script src="${_js}/nicescroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<!-- icheck -->
<script src="${_js}/icheck/icheck.min.js" type="text/javascript"></script>

<script src="${_js}/custom.js" type="text/javascript"></script>

<!-- PNotify -->
<script src="${_js}/notify/pnotify.core.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.buttons.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.nonblock.js" type="text/javascript" ></script>
<!-- daterangepicker -->
<script type="text/javascript" src="${_js}/datepicker/moment.min2.js"></script>
<script type="text/javascript" src="${_js}/datepicker/daterangepicker.js"></script>
<script type="text/javascript" src="${_front_js}/date.js"></script>
<script type="text/javascript">
	
	$(document).ready(function () {
        $('input.tableflat').iCheck({
            checkboxClass: 'icheckbox_flat-green',
            radioClass: 'iradio_flat-green'
        });
        $('#reservation').daterangepicker(null, function (start, end, label) {
            //console.log(start.toISOString(), end.toISOString(), label);
        });
    });
   //查询 
	function initData(action) { 
    	var username = $.trim($("#username").val());
    	var match = $("#match option:selected").val();
    	var status = $("#status option:selected").val();
		var money=$("#money").val();
    	var isOffLine = $("#isOffLine option:selected").val();
		var reservation = $("#reservation").val();
    	var reg = /^\d{4}[-]\d{2}[-]\d{2}~\d{4}[-]\d{2}[-]\d{2}$/;
		if(reservation !="" && !reg.test(reservation)){
			new PNotify({
		            	title: '操作提示',
		            	text: '时间格式错误！',
		            	delay: 3e3,
		            	type: 'error'
		        	});
		    return false;
		}
    	if(username != ""){
    		action += "&username="+username;
    	}
    	if(match != "" ){
    		action += "&match="+match;
    	}
    	if(money != ""){
    		action += "&money="+money;
    	}
    	if(isOffLine != ""){
    		action += "&isOffLine="+isOffLine;
    	}
    	if(status != ""){
    		action += "&status="+status;
    	}
    	if(reservation !=""){
    		var splitChar = "~";
    		if(reservation.indexOf(splitChar) != -1){
    			var createTimeBegin = reservation.split(splitChar)[0].trim();
    			var createTimeEnd = reservation.split(splitChar)[1].trim();
    			action += "&createTimeBegin="+createTimeBegin;
    			action += "&createTimeEnd="+createTimeEnd;
    		}
    	}
		window.location.href=action;
	} 
    $(".btn-info").click(function(){
		initData($("#example").attr('data-action'));
	});
    
    //点击线下充值
	$("#offLineOper").click(function(){
		window.location.href="/admin/recharge/offLineRecharge";
	});
	
	
	$("#export").click(function(){
		var count=0;
		var ids=new Array();
		var status = "";
		var index = ${pageInfo.index};
		$(".tbody .tableflat").each(function(){
			if($(this).parent().hasClass('checked')==true){
				ids[count]=$(this).attr("data-id");
				count++;
			}
		})
		$("#example-tab li").each(function(){
			if($(this).hasClass('active')){
    			status=$(this).attr("data-hash");
    		}
		});
		/**
		if(count==0){
			alert("请选择导出记录!");
			return false;
		}
		**/
		var match = $.trim($("#match").find("option:selected").val());
    	var money = $.trim($("#money").val());
    	var reservation = $("#reservation").val();
    	var reg = /^\d{4}[-]\d{2}[-]\d{2}~\d{4}[-]\d{2}[-]\d{2}$/;
    	if(reservation !="" && !reg.test(reservation)){
			new PNotify({
		            	title: '操作提示',
		            	text: '时间格式错误！',
		            	delay: 3e3,
		            	type: 'error'
		        	});
		    return false;
		}
		if(money !=""){
    		if(match == ""){
    			new PNotify({
		            	title: '操作提示',
		            	text: '请先选择匹配符！',
		            	delay: 3e3,
		            	type: 'error'
		        	});  
		        return;
    		}
    	}
		var action="/admin/export/recharge?ids="+ids+"&status="+status+"&index="+index;
				    if(reservation !=""){
		var splitChar = "~";
		if(reservation.indexOf(splitChar) != -1){
			var createTimeBegin = reservation.split(splitChar)[0].trim();
			var createTimeEnd = reservation.split(splitChar)[1].trim();
			action += "&createTimeBegin="+createTimeBegin;
			action += "&createTimeEnd="+createTimeEnd;
		}
	}
		$("#rechargeForm").attr("method","post");
		$("#rechargeForm").attr("action",action);
		$("#rechargeForm").submit();
	});	
	
	    //获取用户账户信息
	$(".btn-user").click(function(){
		var userId = $(this).attr("data-id");
		$.ajax({
			type: "POST",
			url: '/admin/withdraw/getUserInfo',
			data:{"userId":userId},
			async: false,
			success: function(result) {
				if(result.code == -1){
					var data = result.entity;
					$("#usernameI").val(data.username);
					$("#phoneI").val(data.phone);
					$("#realnameI").val(data.realname);
					$("#totalAmountI").val(data.totalAmount.toFixed(2));
					$("#balanceI").val(data.balance.toFixed(2));
					$("#freezenI").val(data.freezen.toFixed(2));
					$("#awaitI").val(data.await.toFixed(2));
					$("#repayI").val(data.repay.toFixed(2));
					$("#totalRechargeI").val(data.totalRecharge.toFixed(2));
					$("#totalWithdrawI").val(data.totalWithdraw.toFixed(2));
				}else {
					alert(result.msg);
				}
			}
		});
	});
</script>

 <script language="javascript" type="text/javascript">  
    $(function () {  
		$('.headings input').on('ifChecked', function(event){
		  $(".tbody :checkbox").iCheck('check');
		});

		$('.headings input').on('ifUnchecked', function(event){
		  $(".tbody :checkbox").iCheck('uncheck');
		});
    }); 
    var createTimeBegin = "<#if createTimeBegin?exists>${createTimeBegin}</#if>";
    var createTimeEnd = "<#if createTimeEnd?exists>${createTimeEnd}</#if>";
    if(createTimeBegin != "" && createTimeEnd != ""){
    	document.getElementById("reservation").value=createTimeBegin+"~"+createTimeEnd
    } 
</script> 